<template>
	<view class="content">
		<headerbox :cixitype="cixi"></headerbox>
		<view class="pages">
			<view class="card">
				<view class="card-body">
					<view class="title">USDT钱包</view>
					<view class="fromitem">
						<view class="icon">
							<image src="../../static/timg/yaoshi.png" mode=""></image>
						</view>
						<input class="input" type="text" placeholder="钱包地址" v-model="qbaddr" />
						<view class="label">钱包地址</view>
						<view class="right">必须</view>
					</view>
					<view class="btns" @click="submit()" v-if="!issubmit">更新</view>
				</view>
			</view>
		</view>
		<view class="footer-bar" :class="cixi ? '':'footer-bar-detached'">
			<view class="fbitem" @click="goSwichPage('/pages/index/index')">
				<view class="image">
					<image src="../../static/timg/shouye.png" mode=""></image>
				</view>
				<view class="text">首页</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/contract/contract')">
				<view class="image">
					<image src="../../static/timg/heyue.png" mode=""></image>
				</view>
				<view class="text">合约</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/assets')">
				<view class="image">
					<image src="../../static/timg/zichan.png" mode=""></image>
				</view>
				<view class="text">资产</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/claim')">
				<view class="image">
					<image src="../../static/timg/suopei.png" mode=""></image>
				</view>
				<view class="text">索赔</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerbox from '@/pages/header.vue'
	import {
		set_bank,
		getuserinfo
	} from '@/api/api.js'
	export default{
		components:{
			headerbox
		},
		data(){
			return{
				cixi:false,
				qbaddr:'',
				name: 'Tron',
				issubmit:true
			}
		},
		onLoad() {
			this.initdata()
		},
		onPageScroll(e) {
			if(e.scrollTop > 0){
				this.cixi = true
			}else{
				this.cixi = false
			}
		},
		methods:{
			initdata() {
				let token = uni.getStorageSync('token')
				let datas = {
					type:1
				}
				getuserinfo(datas).then(res => {
					if (res.statusCode == 200) {
						this.issubmit = res.data.data.member.usdt_address != ''&& res.data.data.member.usdt_address!=null ? true : false
						this.qbaddr = res.data.data.member.usdt_address
					}
			
				})
			},
			submit(){
				let that = this;
				if (this.qbaddr == '') {
					uni.showToast({
						title: '请输入地址',
						icon: 'error',
						duration: 2000
					});
					return false
				}
				let datas = {
					username4: this.name ? this.name : '',
					type: 4,
					usdt_address: this.qbaddr
				}
				set_bank(datas).then(res => {
					if (res.data.status.errorCode == 0) {
						uni.showToast({
							title: res.data.status.msg,
							icon: 'success',
							duration: 2000
						});
						this.initdata()
					} else {
						uni.showToast({
							title: res.data.status.msg,
							icon: 'error',
							duration: 2000
						});
					}
				}).catch(err => {
					console.log(err)
				})
			},
			goSwichPage(page){
				uni.navigateTo({
					url:page
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	*{
		box-sizing: border-box;
	}
	.content{
		width: 100%;
		min-height: 100vh;
		background-color: #f1f1f7;
		color: #747474 !important;
	}
	.pages{
		padding-top: calc(calc(110rpx + 60rpx) + env(safe-area-inset-top));
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
	}
	.card{
		width: 94%;
		margin: 0 auto;
		border-radius: 20rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		word-wrap: break-word;
		margin-bottom: 30rpx;
		background-color: #fff;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
	}
	.card-body{
		z-index: 3;
		flex: 1 1 auto;
		padding: 40rpx;
	}
	.title{
		width: 100%;
		line-height: 80rpx;
		text-align: center;
		background-color: #4A89DC;
		border-color: #4A89DC;
		color: #FFF !important;
		font-size: 26rpx;
		font-weight: 600;
		border-radius: 30rpx;
		margin-bottom: 40rpx;
	}
	.fromitem{
		position: relative;
		margin-bottom: 40rpx;
	}
	.icon{
		position: absolute;
		width: 80rpx;
		height: 106rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}
	.icon image{
		width: 28rpx;
		height: 28rpx;
	}
	.fromitem .input{
		width: 100%;
		height: 106rpx;
		line-height: 102rpx;
		border: 2rpx solid rgba(0, 0, 0, 0.07) !important;
		padding-left: 80rpx;
		padding-right: 30rpx;
		border-radius: 20rpx;
		font-size: 24rpx;
		outline:0;
		color: #000;
	}
	.label{
		position: absolute;
		top: -10rpx;
		height: 20rpx;
		line-height: 20rpx;
		left: 0;
		font-size: 22rpx;
		text-transform: uppercase;
		font-family: "Nunito", sans-serif;
		font-weight: 700;
		transition: all 250ms ease;
		padding-left: 2px !important;
		padding-right: 5px !important;
		color: #0f1117;
		transform: translateX(80rpx) !important;
		margin-left: -64rpx !important;
	}
	.right{
		position: absolute;
		top: 0px;
		right: 20rpx;
		height: 106rpx;
		line-height: 106rpx;
		pointer-events: none;
		font-size: 20rpx;
		opacity: 0.5;
		color: #747474 !important;
	}
	.btns{
		margin-top: 60rpx;
		width: 100%;
		height: 88rpx;
		line-height: 88rpx;
		text-align: center;
		font-size: 24rpx;
		font-weight: 700;
		color: #fff;
		background-color: #4A89DC !important;
		box-shadow: 0 5px 14px 0 rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;
	}
	
	.footer-bar{
		background-color: rgba(255, 255, 255, 0.95);
		padding: 0px 20rpx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		z-index: 98;
		backdrop-filter: blur(20rpx);
		display: flex;
		text-align: center;
		transition: all 250ms ease;
		height: calc(120rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
	}
	.footer-bar.footer-bar-detached{
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		bottom: 30rpx !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
		height: 120rpx !important;
	}
	.fbitem{
		color: #818181;
		position: relative;
		flex: 1 1 auto;
		padding-top: 24rpx;
		
		.image{
			height: 48rpx;
			margin-top: -4rpx;
			
			image{
				width: 36rpx;
				height: 36rpx;
			}
		}
		.text{
			height: 48rpx;
			margin-top: -6rpx;
			font-size: 24rpx;
			opacity: 0.7;
			color: #818181;
		}
	}
</style>